package util

import (
	"common-admin/config"
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
)

var ctx = context.Background()

func GetGoredis() {
	conf := config.GetConfig()
	redifConf := conf.Data.Redis
	address := fmt.Sprintf("%s:%s", redifConf.Host, redifConf.Port)
	rdb := redis.NewClient(&redis.Options{
		Addr:     address,
		Password: redifConf.Password, // no password set
		DB:       redifConf.Database, // use default DB
	})

	pong, err := rdb.Ping(ctx).Result()
	fmt.Println(pong, err)
}
